<template>
  <div class="app-container">
    <van-tree-select height="55vw" :items="items" :main-active-index.sync="active">
      <template #content>
        <div v-for="(item,index) in items" :key="item.id">
          <div v-for="item1 in item.children" :key="item1.id">
            <van-image
              :src="item1.images"
              v-if="active === index"
            />
          </div>
        </div>
      </template>
    </van-tree-select>
  </div>
</template>
<script>
export default {
  data () {
    return {
      active: 0,
      items: [
        {
          id: 1,
          text: '城市1',
          badge: 3,
          dot: true,
          className: 'my-class',
          children: [
            {
              text: '温州',
              id: 1,
              images: 'https://smart-shop.itheima.net/uploads/10001/20230320/43db9277c381eef488544252757ebef8.png'
            },
            {
              text: '杭州',
              id: 2,
              images: 'https://smart-shop.itheima.net/uploads/10001/20230320/ff30e80831c1f16f4d090116f55c0912.png'
            }
          ]
        },
        {
          id: 2,
          text: '城市2',
          badge: 3,
          dot: true,
          className: 'my-class',
          children: [
            {
              text: '温州',
              id: 1,
              images: 'https://img01.yzcdn.cn/vant/apple-1.jpg'
            },
            {
              text: '杭州',
              id: 2,
              images: 'https://img01.yzcdn.cn/vant/apple-1.jpg'
            }
          ]
        }
      ]
    }
  }
}
</script>
